Vectorized query execution is a significant performance improvement on current row pipeline execution engines, which are used by some traditional databases. In the traditional pipeline execution engine, the data unit between each iterator is a row, while the vectorized query execution uses a vector. A benefit of using a vector as a data unit is to amortize the per-row overhead to a vector of rows. One key factor of vectorized query execution is the vector length or size, where both too small and too large sizes can hurt performance. In general, the larger the vector size, the more per-row overhead can be amortized leading to better performance. However, a larger size vector needs more memory to store it, which can incur cache misses and hence hurt performance. There is no unique best setting for vector size as it is also related to the query and hardware settings. The optimal length can be different for different query and different hardware settings. For example, a larger L1 cache allows a larger size vector. There is a need for a method that selects the optimal vector size for performance according to software and hardware needs.